<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .das {
            width: 100px;
            height: 100px;
            border: 1px solid pink;
            position: absolute;
        }
    </style>
</head>

<body>

</body>

<script>
    window.onload = function () {

        document.addEventListener('mousedown', e => {

            // 创建虚拟div
            const 虚拟div = document.createElement('div')
            虚拟div.classList.add('das')
            document.body.appendChild(虚拟div)

            document.addEventListener('mousemove', e => {

                虚拟div.style.left = e.clientX + 'px'
                虚拟div.style.top = e.clientY + 'px'

            })

            document.addEventListener('mouseup', e => {

                虚拟div.style.left = e.clientX + 'px'
                虚拟div.style.top = e.clientY + 'px'
                document.body.removeChild(虚拟div)

            })
        })
    }
</script>

</html>